var a = require("../../../../@babel/runtime/helpers/interopRequireDefault")(require("../../../../utils/util.js")), t = getApp();

Page({
    data: {
        select: !1,
        is_name: "Auction",
        keyword: "",
        status: "1",
        page: 1,
        current_page: 1,
        last_page: 1,
        is_new: "",
        is_recommend: "",
        auctioneer_id: ""
    },
    onLoad: function(a) {
        console.log(a), a.is_recommend && (this.setData({
            is_recommend: a.is_recommend
        }), wx.setNavigationBarTitle({
            title: "推荐拍品"
        })), a.is_new && (this.setData({
            is_new: a.is_new
        }), wx.setNavigationBarTitle({
            title: "最新拍品"
        })), this.getSearch();
    },
    toDetail: function(a) {
        var t = a.currentTarget.dataset.id.goods_id, e = a.currentTarget.dataset.id.member_id ? a.currentTarget.dataset.id.member_id : a.currentTarget.dataset.id.auctioneer_id;
        wx.navigateTo({
            url: "/packageD/auction/auction/auction_good/auction_good?id=" + t + "&member_id=" + e
        });
    },
    gosearch: function() {
        wx.navigateTo({
            url: "/packageD/auction/auction/auction_search/auction_search"
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        if (this.data.current_page >= this.data.last_page) wx.showToast({
            title: "没有更多了",
            icon: "none",
            duration: 1e3
        }); else {
            var a = this.data.page + 1;
            this.setData({
                page: a
            }), this.getNew();
        }
    },
    onShareAppMessage: function() {},
    getSearch: function() {
        var e = this, n = t.getNetAddresss("plugin.auction.api.index.getAuctionData"), i = {
            keyword: e.data.keyword,
            status: e.data.status,
            auc_status: "",
            is_new: e.data.is_new,
            is_recommend: e.data.is_recommend,
            auctioneer_id: "",
            art: "getSearch",
            page: this.data.page
        };
        t._postNetWork({
            url: n,
            data: i,
            success: function(t) {
                var n = t.data;
                if (1 == n.result) {
                    if (0 == n.data.getSearch.data.length) return 1 == e.data.status ? wx.showToast({
                        title: "没有相关拍品",
                        icon: "none",
                        duration: 1e3
                    }) : 2 == e.data.status && wx.showToast({
                        title: "没有相关拍卖官",
                        icon: "none",
                        duration: 1e3
                    }), void e.setData({
                        datas: []
                    });
                    for (var i = 0; i < n.data.getSearch.data.length; i++) n.data.getSearch.data[i].end_shooting = a.default.formatTimeTwo(n.data.getSearch.data[i].end_shooting, "Y-M-D h:m:s");
                    e.setData({
                        datas: n.data.getSearch.data,
                        current_page: n.data.getSearch.current_page,
                        last_page: n.data.getSearch.last_page
                    });
                } else wx.showToast({
                    title: n.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getNew: function() {
        var e = this, n = t.getNetAddresss("plugin.auction.api.index.getAuctionData"), i = {
            keyword: e.data.keyword,
            status: e.data.status,
            auc_status: "",
            is_new: e.data.is_new,
            is_recommend: e.data.is_recommend,
            auctioneer_id: "",
            art: "getSearch",
            page: this.data.page
        };
        t._postNetWork({
            url: n,
            data: i,
            success: function(t) {
                var n = t.data;
                if (1 == n.result) {
                    if (0 == n.data.getSearch.data.length) return 1 == e.data.status ? wx.showToast({
                        title: "没有相关拍品",
                        icon: "none",
                        duration: 1e3
                    }) : 2 == e.data.status && wx.showToast({
                        title: "没有相关拍卖官",
                        icon: "none",
                        duration: 1e3
                    }), void e.setData({
                        datas: []
                    });
                    for (var i = 0; i < n.data.getSearch.data.length; i++) n.data.getSearch.data[i].end_shooting = a.default.formatTimeTwo(n.data.getSearch.data[i].end_shooting, "Y-M-D h:m:s");
                    e.setData({
                        datas: this.data.datas.concat(n.data.getSearch.data),
                        current_page: n.data.getSearch.current_page,
                        last_page: n.data.getSearch.last_page
                    });
                } else wx.showToast({
                    title: n.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    }
});